package jesss.commands;

/**
 * User: Lee
 * Date: 8/24/13
 * Time: 1:02 PM
 */
public enum CommandType {
    Unknown(0, "unk", "unknown"),
    ListBuckets(1, "lbs", "listBuckets"),
    ListObjects(2, "los", "listObjects"),
    CreateBucket(3, "cb", "createBucket"),
    DeleteBucket(4, "db", "deleteBucket"),
    PutObject(5, "po", "putObject"),
    GetObject(6, "go", "getObject"),
    CopyObject(7, "co", "copyObject"),
    DeleteObject(8, "do", "deleteObject"),
    DownloadDirectory(9, "dd", "downloadDirectory"),
    MoveObject(10, "mo", "moveObject"),
    UploadDirectory(11, "ud", "uploadDirectory"),
    SearchObject(12, "so", "searchObject"),
    SearchObjects(13, "sos", "searchObjects");


    private int id;
    private String shortName;
    private String name;

    private CommandType(int id, String shortName, String name) {
        this.id = id;
        this.shortName = shortName;
        this.name = name;
    }

    public static CommandType fromShortName(String shortName) {
        switch(shortName) {
            case "lbs": case "listBuckets": return ListBuckets;
            case "los": case "listObjects": return ListObjects;
            case "cb": case "createBucket": return CreateBucket;
            case "db": case "deleteBucket": return DeleteBucket;
            case "po": case "putObject": return PutObject;
            case "go": case "getObject": return GetObject;
            case "co": case "copyObject": return CopyObject;
            case "do": case "deleteObject": return DeleteObject;
            case "dd": case "downloadDirectory":  return DownloadDirectory;
            case "mo": case "moveObject": return MoveObject;
            case "ud": case "uploadDirectory": return UploadDirectory;
            case "so":case "searchObject": return SearchObject;
            case "sos":case "searchObjects": return SearchObjects;
            default: return Unknown;
        }
    }
}
